# --------------------------------------------------------------------
#
#	Setup initial environment
#
# --------------------------------------------------------------------
Add-PSSnapin TabularDatabaseCmdlets

# --------------------------------------------------------------------
#
#	Common Variables
#
# --------------------------------------------------------------------
$server = 'localhost'
$databaseName = 'AdventureWorks Tabular PowerShell 2012'

# --------------------------------------------------------------------
#
#	Create Database
#
# --------------------------------------------------------------------
$datasourceOledbConnectionString = 'Provider=SQLOLEDB;Data Source=localhost;Integrated Security=SSPI;Initial Catalog=AdventureWorksDW2012'
$connectionName = 'AdventureWorks Tabular PowerShell 2012'

Add-TabularDatabase $server $databaseName -datasourceOledbConnectionString $datasourceOledbConnectionString -connectionName $connectionName


# --------------------------------------------------------------------
#
#	Create Date as the first table and have it be the model date table
#
# --------------------------------------------------------------------
$cubeName = 'AdventureWorks Tabular PowerShell 2012 Cube'

Add-FirstTableToTabularDatabase $server $databaseName -cubeName $cubeName -datasourceTableName DimDate -tableName Date -process ProcessFull -modelDateColumn FullDateAlternateKey 


# --------------------------------------------------------------------
#
#	Create tables
#
# --------------------------------------------------------------------


Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimCurrency           -tableName Currency               -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimCustomer           -tableName Customer               -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimEmployee           -tableName Employee               -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimGeography          -tableName Geography              -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimProduct            -tableName Product                -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimProductCategory    -tableName 'Product Category'     -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimProductSubcategory -tableName 'Product Subcategory'  -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimPromotion          -tableName Promotion              -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimReseller           -tableName Reseller               -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName DimSalesTerritory     -tableName 'Sales Territory'      -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName FactInternetSales     -tableName 'Internet Sales'       -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName FactProductInventory  -tableName 'Product Inventory'    -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName FactResellerSales     -tableName 'Reseller Sales'       -process ProcessFull 
Add-TableToTabularDatabase $server $databaseName -datasourceTableName FactSalesQuota        -tableName 'Sales Quota'          -process ProcessFull 
